package com.lijian.study.mongo.Entity;

import java.time.LocalDateTime;
import java.util.List;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Document(collection = "users")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class User {
    @Id
    private String id;
    private String name;
    private String email;

    @DBRef(db = "test")
    private List<Address> addresses; // 用户的地址集合

    @DBRef(db = "test")
    private List<Role> roles; // 用户的角色集合

    @CreatedDate // 标记为创建日期
    private LocalDateTime createdDate;

    @LastModifiedDate // 标记为最后修改日期
    private LocalDateTime lastModifiedDate;

}
